package com.ylfstu.innerclass;

public class AnonymousInnerClassDetail {
    public static void main(String[] args) {
        Outer03 outer03 = new Outer03();
        outer03.f1();
    }
}

class Outer03 {
    private int n1 = 99;

    public void f1() {
        //创建一个匿名内部类
        Person person = new Person() {
            @Override
            public void hi() {
                System.out.println("匿名内部类重写了hi方法");
            }
        };
        person.hi();//动态绑定，运行类型是Outer03$1

        //也可以直接调用
        new Person() {
            @Override
            public void hi() {
                System.out.println("匿名内部类重写了hi方法，哈哈哈..." + n1);
            }
        }.hi();

    }
}

class Person {
    public void hi() {

    }
}
